from typing import List
from list_node import ListNode

class Solution:
    def Merge(self , pHead1: ListNode, pHead2: ListNode) -> ListNode:
        res = ListNode(0)
        head = res
        while pHead1 and pHead2:
            if(pHead1.val <= pHead2.val):
                head.next = pHead1
                pHead1 = pHead1.next
            else:
                head.next = pHead2
                pHead2 = pHead2.next
            head = head.next
        if pHead1:
            head.next = pHead1
        else:
            head.next = pHead2
        return res.next
